//
// Created by 吴喆 on 2020/3/3.
//

#ifndef SUMMER_GUI_H
#define SUMMER_GUI_H

#include <imgui/imgui.h>
#include <imgui/imgui_impl_glfw.h>
#include <imgui/imgui_impl_opengl3.h>
#include <iostream>
#include "Time.h"
#include "../util/Console.h"
#import <vector>

extern const char *glslVersion;

class Gui {
public:
    static Gui* getInstance() {
        return imGui;
    }

    static std::vector<std::string> texts;

    void init(GLFWwindow *win, int screenWidth_, int screenHeight_) {
        ImGui_ImplGlfw_InitForOpenGL(win, true);
        ImGui_ImplOpenGL3_Init(glslVersion);
        Gui::lastWidth = screenWidth_;
        Gui::lastHeight = screenHeight_;
        Gui::currWidth = screenWidth_;
        Gui::currHeight = screenHeight_;
        this->win = win;
    }

    void zoomCallback(float width, float height) {
        Gui::currWidth = width;
        Gui::currHeight = height;
        Console::INFO(std::to_string(width));
    }

    void showPlayerPos(float x, float y);
    void showPlayerPos1(float x, float y);

    void render();

private:
    Gui() {
        ImGui::CreateContext();
        ImGuiIO &io = ImGui::GetIO();
        ImGui::StyleColorsDark();
        io.Fonts->AddFontFromFileTTF("../fonts/simhei.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
    }
    static float currWidth, currHeight;
    static float lastWidth, lastHeight;
    static Gui *imGui;
    GLFWwindow *win;

    float posX, posY;
    float posX1, posY1;
};



#endif //SUMMER_GUI_H
